@extends('develop.layoutEdit')

@section('css')
<style>
    .layer-go-back{
        display:none;
    }
</style>
@endsection


@section('title')
    <li class="cur">
        <span>会员设置</span>
    </li>
@endsection

@section('content')

<div class="form-group">
    <label  class="col-sm-3 control-label"><span class="red pr5">*&nbsp;</span>是否会员转换：</label>
    <div class="col-sm-9">
        <div class="layui-form">
            <input type="radio"  name="is_change_customer_id" value="1"  title="是" @if( !isset($configure['is_change_customer_id']) || $configure['is_change_customer_id'] == 1 ) checked @endif>
            <input type="radio"  name="is_change_customer_id" value="0"  title="否" @if( isset($configure['is_change_customer_id']) && $configure['is_change_customer_id'] == 0 ) checked @endif>
        </div>
    </div>
</div>

<div class="form-group">
    <label  class="col-sm-3 control-label"><span class="red pr5">*&nbsp;</span>积分页是否显示门店编号：</label>
    <div class="col-sm-9">
        <div class="layui-form">
            <input type="radio"  name="points_page_show_mall_code" value="1" title="是" @if( !isset($configure['points_page_show_mall_code']) || $configure['points_page_show_mall_code'] == 1 ) checked @endif>
            <input type="radio"  name="points_page_show_mall_code" value="0" title="否" @if( isset($configure['points_page_show_mall_code']) && $configure['points_page_show_mall_code'] == 0 ) checked @endif>
        </div>
    </div>
</div>

<div class="form-group">
    <label class="col-sm-3 control-label"><span class="red pr5">*&nbsp;</span>登录注册方式：</label>
    <div class="col-sm-9">
        <div class="layui-form">
            <input type="radio" name="login_register_type" value="1" title="登录+注册" lay-filter="nocheck" @if( !isset($configure['login_register_type']) || $configure['login_register_type'] == 1 ) checked @endif>
            <input type="radio" name="login_register_type" value="2" title="快捷登录" lay-filter="check" @if( isset($configure['login_register_type']) && $configure['login_register_type'] == 2 ) checked @endif>
            <input type="radio" name="login_register_type" value="3" title="第三方粉丝自动注册" lay-filter="nocheck" @if( isset($configure['login_register_type']) && $configure['login_register_type'] == 3 ) checked @endif>
        </div>
    </div>
</div>

<div class="form-group" id="login_content" @if( $configure['login_register_type'] != 2 )style="display: none;"@endif>
    <label class="col-sm-3 control-label"><span class="red pr5">*&nbsp;</span>登录方式：</label>
    <div class="col-sm-9" id="login_Y">
        <div class="layui-form">
            <input type="radio" name="login_type" value="1" title="手机号+短信验证码" @if( !isset($configure['login_type']) || $configure['login_type'] == 1 ) checked @endif>
            <input type="radio" name="login_type" value="2" title="手机号+密码" @if( isset($configure['login_type']) && $configure['login_type'] == 2 ) checked @endif>
        </div>
    </div>
</div>

<div class="form-group">
    <label class="col-sm-3 control-label" ><span class="red pr5"></span> 注册成功后跳转页面：</label>
    <div class="col-sm-5">
        <input type="text" placeholder="http://"  name="register_to_location_url" id="register_to_location_url"  class="form-control" value="{{$configure['register_to_location_url'] or ''}}">
    </div>
</div>

<div class="form-group">
    <label class="col-sm-3 control-label"><span class="red pr5">*&nbsp;</span>会员开卡：</label>
    <div class="col-sm-9">
        <div class="layui-form">
            <input type="radio" name="open_card" class="open_card" value="1" title="不开卡" lay-filter="no_open_card" checked>
            <input type="radio" name="open_card" class="open_card"  value="2" title="注册时开卡" lay-filter="no_open_card" @if( isset($configure['open_card']) && $configure['open_card'] == 2) checked @endif>
            <input type="radio" name="open_card" class="open_card"  value="3" title="业务场景开卡" lay-filter="open_card" @if( isset($configure['open_card']) && $configure['open_card'] == 3) checked @endif>
            <input type="radio" name="open_card" class="open_card"  value="4" title="全局场景开卡" lay-filter="no_open_card" @if( isset($configure['open_card']) && $configure['open_card'] == 4) checked @endif>
        </div>
    </div>
</div>

<div class="form-group">
    <label class="col-sm-3 control-label"><span class="red pr5">*&nbsp;</span>会员绑卡：</label>
    <div class="col-sm-9" >
        <div class="layui-form">
            <input type="radio" name="bind_card" class="bind_card" value="1" title="不绑卡" lay-filter="no_open_card" checked>
            <input type="radio" name="bind_card" class="bind_card"  value="2" title="注册时绑卡" lay-filter="no_open_card" @if( isset($configure['bind_card']) && $configure['bind_card'] == 2) checked @endif>
            <input type="radio" name="bind_card" class="bind_card"  value="3" title="业务场景绑卡" lay-filter="open_card" @if( isset($configure['bind_card']) && $configure['bind_card'] == 3) checked @endif>
            <input type="radio" name="bind_card" class="bind_card"  value="4" title="全局场景绑卡" lay-filter="no_open_card" @if( isset($configure['bind_card']) && $configure['bind_card'] == 4) checked @endif>
        </div>
    </div>
</div>

<div class="form-group" id="scene" @if( $configure['bind_card'] !=3 && $configure['open_card'] !=3 ) style="display: none;" @endif>
    <label  class="col-sm-3 control-label"><span class="red pr5">*&nbsp;</span>业务场景：</label>
    <div class="col-sm-9 form-inline">
        <div class="layui-form">
            <input type="checkbox"  name="card_scene" class="card_scene" value="1" title="会员中心页" @if( !isset($configure['card_scene']) || in_array(1,$configure['card_scene'])) checked @endif>
            <input type="checkbox"  name="card_scene" class="card_scene" value="2" title="会员积分页" @if(isset($configure['card_scene']) && in_array(2,$configure['card_scene']))checked @endif>
            <input type="checkbox"  name="card_scene" class="card_scene"  value="3" title="会员余额页" @if(isset($configure['card_scene']) && in_array(3,$configure['card_scene']))checked @endif>
            <input type="checkbox"  name="card_scene" class="card_scene"  value="4" title="会员卡券页" @if(isset($configure['card_scene']) && in_array(4,$configure['card_scene']))checked @endif>
        </div>
    </div>
</div>

<div class="form-group" id="is_close_card_layer" @if( $configure['bind_card'] !=3 && $configure['open_card'] !=3 ) style="display: none;" @endif>
    <label  class="col-sm-3 control-label"><span class="red pr5">*&nbsp;</span>是否可关闭开卡绑卡弹出层：</label>
    <div class="col-sm-9 form-inline">
        <div class="layui-form">
            <input type="radio"  name="is_close_card_layer" value="1" title="是" checked>
            <input type="radio"  name="is_close_card_layer" value="0" title="否" @if( isset($configure['is_close_card_layer']) && $configure['is_close_card_layer'] == 0) checked @endif>
        </div>
    </div>
</div>

<div class="form-group">
    <label  class="col-sm-3 control-label"><span class="red pr5">*&nbsp;</span>是否升级会员等级：</label>
    <div class="col-sm-9" >
        <div class="layui-form">
            <input type="radio"  name="is_upgrade_customer_rank" value="1" title="是" @if( isset($configure['is_upgrade_customer_rank']) && $configure['is_upgrade_customer_rank'] == 1) checked @endif>
            <input type="radio"  name="is_upgrade_customer_rank" value="0" title="否" @if( !isset($configure['is_upgrade_customer_rank']) || $configure['is_upgrade_customer_rank'] == 0) checked @endif>
        </div>
    </div>
</div>

<div class="form-group">
    <label  class="col-sm-3 control-label"><span class="red pr5">*&nbsp;</span>是否导出会员积分：</label>
    <div class="col-sm-9 form-inline">
        <div class="layui-form">
            <input type="radio"  name="is_export_customer_points" value="1" title="是" @if( isset($configure['is_export_customer_points']) && $configure['is_export_customer_points'] == 1) checked @endif>
            <input type="radio"  name="is_export_customer_points" value="0" title="否" @if( !isset($configure['is_export_customer_points']) || $configure['is_export_customer_points'] == 0) checked @endif>
        </div>
        <span class="help-block">导出会员信息时使用</span>
    </div>
</div>

<div class="form-group">
    <label  class="col-sm-3 control-label"><span class="red pr5">*&nbsp;</span>是否同步积分余额到微信卡包：</label>
    <div class="col-sm-9">
        <div class="layui-form">
            <input type="radio"  name="is_sync_to_wechat_card" value="1" title="是" @if( isset($configure['is_sync_to_wechat_card']) && $configure['is_sync_to_wechat_card'] == 1) checked @endif>
            <input type="radio"  name="is_sync_to_wechat_card" value="0" title="否" @if( !isset($configure['is_sync_to_wechat_card']) || $configure['is_sync_to_wechat_card'] == 0) checked @endif>
        </div>
    </div>
</div>

<div class="form-group">
    <label  class="col-sm-3 control-label"><span class="red pr5">*&nbsp;</span>是否消费时按会员等级赠送积分：</label>
    <div class="col-sm-9">
        <div class="layui-form">
            <input type="radio"  name="is_consume_to_give_points" value="1" title="是" @if( isset($configure['is_consume_to_give_points']) && $configure['is_consume_to_give_points'] == 1) checked @endif>
            <input type="radio"  name="is_consume_to_give_points" value="0" title="否" @if( !isset($configure['is_consume_to_give_points']) || $configure['is_consume_to_give_points'] == 0) checked @endif>
        </div>
    </div>
</div>

<div class="form-group">
    <label  class="col-sm-3 control-label"><span class="red pr5">*&nbsp;</span>是否显示结婚日期：</label>
    <div class="col-sm-9" >
        <div class="layui-form">
            <input type="radio"  name="is_show_customer_marry_day" value="1" title="是" @if( isset($configure['is_show_customer_marry_day']) && $configure['is_show_customer_marry_day'] == 1) checked @endif>
            <input type="radio"  name="is_show_customer_marry_day" value="0" title="否" @if( !isset($configure['is_show_customer_marry_day']) || $configure['is_show_customer_marry_day'] == 0) checked @endif>
        </div>
    </div>
</div>

<div class="form-group">
    <label class="col-sm-3 control-label"></label>
    <div class="col-sm-9">
        <input type="hidden" name="function_id" id="function_id" value="{{ $function_id or ''}}">
        <input type="button"  value="保存" onclick="func.edit();" class="btn btn-success" >
    </div>
</div>

@endsection
@section('js')
    <script>
        layui.use(['form'], function(){

            var form = layui.form();

            form.on('radio(check)', function(data){
                if ( this.checked ) {
                    $('#login_content').show();
                }
            });
            form.on('radio(nocheck)', function(data){
                if ( this.checked ) {
                    $('#login_content').hide();
                }
            });
            form.on('radio(open_card)', function(data){
                if ( this.checked ) {
                    $('#scene').show();
                    $('#is_close_card_layer').show();
                }
            });
            form.on('radio(no_open_card)', function(data){

                var open_card = $('input[name="open_card"]:checked').val();
                var bind_card = $('input[name="bind_card"]:checked').val();

                if ( this.checked && open_card != 3 && bind_card != 3) {
                    $('#scene').hide();
                    $('#is_close_card_layer').hide();
                }
            });
        });

        var func = {

            //保存
            edit:function(){

                var message_log = '' ;
                var configure = E.getFormValues('edit-form') ;

                //参数判断
                if( E.isEmpty( configure.function_id ) || !E.isInt( configure.function_id ) ) {
                    message_log += '参数错误<br/>' ;
                }

                if(  configure.open_card ==3 || configure.bind_card ==3 ) {
                    if( E.isEmpty( configure.card_scene ) ) {
                        message_log += '业务场景不能为空<br/>' ;
                    }
                }

                var reg = /http:\/\/.+/i;
                if ( !E.isEmpty(configure.register_to_location_url) ) {
                    if ( !reg.test( configure.register_to_location_url ) ) {
                      message_log += '跳转页面链接必须是正确的URL(以http://格式开头)<br/>';
                    }
                }

                if( message_log ) {
                    layer.alert( message_log , { icon:2 });
                    return false ;
                }

                layer.confirm("您确认保存该设置吗？",{icon:3,offset:'50px'}, function ( index ){
                    layer.close( index );
                    E.ajax( {
                        type:'get',
                        url: '/lar/develop/function/store/'+function_id,
                        data: configure,
                        dataType:'json',
                        // 返回值判断
                        success: function ( obj ){

                            if ( obj.code == 200 ) {
                                layer.alert( obj.message , { icon: 1,time : 1500 } ) ;
                            } else {
                                layer.alert( obj.message , { icon: 2 } ) ;
                            }
                        }
                    } ) ;
                });
            }

        };
    </script>
@endsection